package vehement.game.nodes;

//import java.nio.ByteBuffer;
//import java.nio.ByteOrder;
//import java.nio.IntBuffer;

import java.util.ArrayList;
import vehement.game.interfaces.Drawable;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;

/**
 * This is a very minimal implementation of a scene node for a scene graph
 * @author bloodred
 *
 */
public class SceneNode implements Drawable {
	public ArrayList<Drawable> childList;
	
	public Vector3f offset;   
	public Vector3f rotation; //euler angle, eww gimbel lock
	
	public SceneNode(){
		childList = new ArrayList<Drawable>();
		offset = new Vector3f(0.f,0.f,0.f);   
		rotation = new Vector3f(0.f,0.f,0.f); 
	}
	public SceneNode(Vector3f iOff, Vector3f iRot){
		childList = new ArrayList<Drawable>();
		offset = iOff;
		rotation = iRot;
	}
	
	public void draw(){
		//gl
		GL11.glPushMatrix();
	//	GL11.glColor4f(1.f, 1.f, 1.f, 1.f);
		
		GL11.glRotatef(rotation.x,  1, 0, 0);
		GL11.glRotatef(rotation.y,  0, 1, 0);
		GL11.glRotatef(rotation.z,  0, 0, 1);
        
		GL11.glTranslatef(offset.x, offset.y, offset.z);
		
        for (int i=0; i < childList.size(); i++){
        	childList.get(i).draw();
        }
        GL11.glPopMatrix();
	}
	
	
	public void addChild(SceneNode addto){
		childList.add(addto);
	}
	public boolean removeChild(Drawable remove){
		return childList.remove(remove); 
	}
	
	
}
